#include<iostream>
#include<stack>
#include<string>
#include<cstring>

using namespace std;

const int MAX = 1001;

int main()
{
	int n;
	int array[MAX];
	while(cin>>n)
	{
		if(n==0)
		{
		    break;
		}
		//cout<<"n = "<<n<<endl;
		while(cin>>array[0])
		{
			stack<int> A,B,buffer;
			if(array[0]==0)
			{
				break;
			}
			for(int i=1;i<n;i++)
			{
				cin>>array[i];
			}
			for(int i=n-1;i>=0;i--)
			{
				//cout<<array[i]<<" ";
				B.push(array[i]);
				A.push(i+1);
			}

			while( !B.empty() )
			{
				if( buffer.empty() || B.top() > buffer.top() )
				{
					while( !B.empty() && !A.empty() && B.top() >= A.top() )
					{
                        //cout<<"B.top() = "<<B.top()<<" A.top() = "<<A.top()<<endl;
						int tmp = A.top();
						//cout<<"tmp = "<<tmp<<endl;
						buffer.push(tmp);
						A.pop();
					}
					B.pop();
					buffer.pop();
					continue;
				}
				else if( !buffer.empty() && !B.empty() && buffer.top()==B.top() )
				{
					B.pop();
					buffer.pop();
					continue;
				}
				else if( !buffer.empty() && !B.empty() && B.top() < buffer.top() )
				{
					break;
				}
			}//while

			if( B.empty() )
			{
				cout<<"Yes"<<endl;
			}
			else
			{
				cout<<"No"<<endl;
			}

		}//while
		cout<<endl;
	}//while
    //system("pause") ;
	return 0;
}
